Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contract Pruning #526

Merged
merged 93 commits into from
Sep 6, 2023
Merged

Contract Pruning #526

merged 93 commits into from
Sep 6, 2023

Conversation

peterjan
Copy link
Member

@peterjan peterjan commented Aug 7, 2023

This PR adds a route to the worker that allows pruning deleted sectors from a contract, effectively enabling contract pruning functionality. I've thoroughly tested it on my local node (on testnet) and ran some tests on arequipa. I manually verified contract root diffs before and after as well as perform some upload/download testing while pruning was taking place and believe it all works as expected.

Old hosts are quite (read: really) slow at modifying the storage obligation. For now I've simply lowered the batch size and added a means of timing out the request. The plan is to have the autopilot impose a 5' timeout and nibble away at the prunable data for contracts with v1.5.9 hosts. New hosts are really fast and don't pose an issue at all. Soon the majority of the network will upgrade to v1.6.0 anyway so I don't think it's a problem.

When this PR is merged I'll add a mechanism to automatically prune contracts when the total amount of prunable data exceeds some threshold, as well as add alerts and (ask to) integrate it in the UI perhaps.

@peterjan peterjan self-assigned this Aug 7, 2023
stores/metadata.go Outdated Show resolved Hide resolved
worker/worker.go Outdated Show resolved Hide resolved
worker/rhpv2.go Outdated Show resolved Hide resolved
@ChrisSchinnerl
Copy link
Member

Seems like jape is failing with Client has wrong response type for POST /rhp/contract/:id/prune (got *int64, should be *uint64)

worker/rhpv2.go Outdated Show resolved Hide resolved
func (w *worker) PruneContract(ctx context.Context, hostIP string, hostKey types.PublicKey, fcid types.FileContractID, lastKnownRevisionNumber uint64) (deleted, remaining uint64, err error) {
err = w.withContractLock(ctx, fcid, lockingPriorityPruning, func() error {
return w.withTransportV2(ctx, hostKey, hostIP, func(t *rhpv2.Transport) error {
return w.withRevisionV2(ctx, defaultLockTimeout, t, hostKey, fcid, lastKnownRevisionNumber, func(t *rhpv2.Transport, rev rhpv2.ContractRevision, settings rhpv2.HostSettings) (err error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we combine withRevisionV2 and withTransportV2? I think they always go hand-in-hand.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha! I noticed this and it's true in most cases but not all cases (e.g. when forming a contract). Fine to leave as-is imo but we can try and combine them, it works in most cases but I thought it was pushing it a little since we'd have to do a weird exception case for form contract. We also don't always use/need the settings.

worker/rhpv2.go Outdated Show resolved Hide resolved
worker/rhpv2.go Outdated Show resolved Hide resolved
@ChrisSchinnerl ChrisSchinnerl merged commit 4b6cfb8 into master Sep 6, 2023
@ChrisSchinnerl ChrisSchinnerl deleted the pj/prune-contracts branch September 6, 2023 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants